Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI-1628] Use shared secret redacting #885

Merged
merged 4 commits into from
Sep 14, 2023
Merged

Conversation

tothszabi
Copy link
Contributor

@tothszabi tothszabi commented Sep 8, 2023

Checklist

Version

Requires a MINOR version update

Context

The secret filtering part of the CLI was essentially moved into the go-utils repo with this PR:
bitrise-io/go-utils#181

It was basically a copy-paste action to be able to share the same filtering code between the CLI and the deploy step.

And now this PR removes the unnecessary code from the CLI and replaces with the one can be found in the go-utils package.

Changes

  • Remove old secret filtering components
  • Pull in new secret redacting feature from go-utils
  • Update code to use new secret redacting

@tothszabi tothszabi marked this pull request as ready for review September 8, 2023 10:09
cli/analytics.go Outdated
@@ -49,12 +50,12 @@ func redactStepInputs(environment map[string]string, inputs []models.Environment
func redactWithSecrets(inputValue string, secrets []string) (string, error) {
src := bytes.NewReader([]byte(inputValue))
dstBuf := new(bytes.Buffer)
secretFilterDst := filterwriter.New(secrets, dstBuf)
redactWriterDst := redactwriter.New(secrets, dstBuf, log.NewLogger())
Copy link
Contributor

@lpusok lpusok Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this "freestanding" log.NewLogger() cause any issues with the structured logging? Can no recall if there are guidelines about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh damn I do not know what I was thinking. Yes, the structured logger needs to be used instead of this one.

This struct requires the logger from the go-utils package but for the structured logging a different one needs to be used. We already had an adapter for this which was used for the analytics. I have made that one public and used it instead.

@tothszabi tothszabi merged commit 2527170 into master Sep 14, 2023
6 checks passed
@tothszabi tothszabi deleted the CI-1628-use-redactwriter branch September 14, 2023 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants